﻿
using Microsoft.AspNet.SignalR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SignalR.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        private readonly ILogger<WeatherForecastController> _logger;
        private readonly IHubContext<ChatHub> _hubContext;

        public WeatherForecastController(ILogger<WeatherForecastController> logger,IHubContext<ChatHub> hubContext)
        {
            _logger = logger;
            _hubContext = hubContext;
        }
        /// <summary>
        /// 向前端推送数据(简单推送)
        /// </summary>
        [HttpGet]
        public void SimplePushInformation()
        {
            _hubContext.Clients.All.SendMessage("ReceiveMessage","你好,世界").Wait(); 
        }
    }
}
